﻿using System.Threading.Tasks;

namespace Sidvall.Data
{
    public interface ISqlProvider
    {
        Task<bool> CreateDatabaseAsync(string connectionString, string database, SqlExceptionBehavior exceptionBehavior);
        Task<int> ExecuteNonQueryAsync(string connectionString, string sqlQuery, SqlExceptionBehavior exceptionBehavior);
        Task<object> ExecuteScalarAsync(string connectionString, string sqlQuery, SqlExceptionBehavior exceptionBehavior);
        Task<TableItemCollection> GetTablesAsync(string connectionString, bool loadRowCount, SqlExceptionBehavior exceptionBehavior);

        string GetFieldName(string tableName, string fieldName);
        string GetTableName(string tableName);
        string GetParameterName(int? index);
        object GetPropertyValue(object fieldValue, DataType valueDataType);

        void InitializeSqlDelete(SqlQuery query, string tableName, SqlQuery whereQuery, RelationItemCollection relations, string orderBySql, int? rowStartIndex, int? rowCount);
        void InitializeSqlSelect(SqlQuery query, string tableName, SqlQuery whereQuery, RelationItemCollection relations, string orderBySql, int? rowStartIndex, int? rowCount,
            string fieldNames);
        void InitializeSqlSelectCount(SqlQuery query, string tableName, SqlQuery whereQuery, RelationItemCollection relations);

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "WildCard")]
        void AddWildCardParameter(SqlQuery query, ComparisonOperator comparisonOperator, string value);
        void InitializeSqlComparison(SqlQuery query, string expression, string value, ComparisonOperator comparisonOperator, object parameterValue);
    }
}
